<%--
  Created by IntelliJ IDEA.
  User: 16398
  Date: 2020/5/30
  Time: 20:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<span style="font-size:18px;">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="admin/css/bootstrap.min.css" type="text/css"/>
    <script language="JavaScript" src="admin/js/jquery.min.js" ></script>
    <title>登录</title>
</head>

<body>

<div style="background: url(admin/img/ic_loginbgk.jpeg); width: 100%; height: 100%;
   background-position:50% 50%; background-size:contain; background-repeat:no-repeat;   " >

    <div class="container">
        <div class="col-md-4"></div>
        <div class="col-md-4" style="background-color:#eee;;margin-top:200px;">
            <div class="row"  >
                <div class="text-center ">
                    <h3>疫情助手后台管理</h3>
                </div>
            </div>

            <form action="#">
                <div class="form-group">
                    <label for="">用户名:&nbsp; &nbsp; <span id="uname" style="font-size:10px; color: red">${message}</span></label>
                    <input type="text" id="user_name" class="form-control" style="color:black;">
                </div>
                <div class="form-group">
                    <label for="">密码&nbsp; &nbsp; <span id="upawd" style="font-size:10px; color: red">${message}</span></label>
                    <input type="password" id="user_password"  class="form-control" style="color:black;">
                </div>
                <div class="form-group">
                    <input type="button" value="登陆" class="btn btn-success form-control" onclick="initDate()">
                </div>
            </form>
        </div>
        <div class="col-md-4"></div>
    </div>
</div>

<script type="text/javascript">
    function initDate(){
        var uname = $("#user_name").val();
        var upawd = $("#user_password").val();

       if($.isEmptyObject(uname)){
            $("#uname").text("请输入用户名");
            return;
        }else {
            $("#uname").text("");
        }
        if($.isEmptyObject(upawd)){
            $("#upawd").text("请输入密码");
            return;
        }else {
            $("#upawd").text("");
        }

        var postUrl = "http://127.0.0.1:8080/YQZS/member/userLogin";
        var url = "http://127.0.0.1:8080/YQZS/index";
        var str = {
            "userLoginName": uname,
            "userLoginPwd": upawd
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            contentType: "application/json; charset=utf-8",
            data:JSON.stringify(str),
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    if (data.msg == "密码错误"){
                        $("#upawd").text("密码错误");
                    }else {
                        $("#uname").text(data.msg);
                    }
                }else {
                    sessionStorage.setItem("user",JSON.stringify(data));
                    location.href = url;
                }

            },
            error:function(xhr,state,errorThrown){
                alert("发生网络错误，错误码为：" + xhr.status)
            }
        });
    }


</script>

</body>
</html>
</span>